package com.example.weather;

import android.text.TextUtils;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.Toast;


import androidx.appcompat.app.AppCompatActivity;


public class Reegister extends AppCompatActivity {

    private EditText etUser;
    private EditText etPassw;
    private EditText etRePassw;
    private RadioButton rbMale;
    private RadioButton rbfaMale;
    private Button btRegister;
    private Button btEixt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reegister);
        initView();
    }

    private void initView() {
        etUser = (EditText) findViewById(R.id.etUser);
        etPassw = (EditText) findViewById(R.id.etPassw);
        etRePassw = (EditText) findViewById(R.id.etRePassw);
        rbMale = (RadioButton) findViewById(R.id.rbMale);
        rbfaMale = (RadioButton) findViewById(R.id.rbfaMale);
        btRegister = (Button) findViewById(R.id.btRegister);
        btEixt = (Button) findViewById(R.id.btEixt);
    }
    public void onclick(View view) {
        switch (view.getId()) {

            case R.id.btRegister:
                String userName = etUser.getText().toString();
                if (TextUtils.isEmpty(userName)) {
                    Toast.makeText(this, "用户名不能为空",Toast.LENGTH_SHORT).show();
                    return;
                }
                String passW = etPassw.getText().toString();
                if (TextUtils.isEmpty(passW)) {
                    etPassw.setError("密码不能为空");
                    return;
                }
                String rePassw = etRePassw.getText().toString();
                if (TextUtils.isEmpty(rePassw)) {
                    etRePassw.setError("确认密码不能为空");
                    return;
                }
                if (!passW.equals(rePassw)) {
                    Toast.makeText(this, "两次密码不一致",Toast.LENGTH_SHORT).show();
                    return;
                }
                char sex;
                if (rbMale.isChecked()) {
                    sex = rbMale.getText().charAt(0);
                } else {
                    sex = rbfaMale.getText().charAt(0);
                }
                StringBuffer s = new StringBuffer();
                break;
            case R.id.btEixt:
                finish();
                break;

        }
    }
}

